package Util;

import java.sql.Connection;
import java.sql.DriverManager;

import javax.swing.JOptionPane;

import Config.Config;

public class DatabaseConnection {

	public static Connection con=null;
	public static String dburl=null;
	public static String username=null;
	public static String password=null;
	
	public static Connection getConn(){
		return con;
	}
	
	public static void setInfo(String dburl,String username,String password){
		DatabaseConnection.dburl=dburl+"?useUnicode=true&characterEncoding=utf8";
		DatabaseConnection.username=username;
		DatabaseConnection.password=password;
	}
	
	public static String reSet(){
		try {
			Class.forName("com.mysql.jdbc.Driver");
			con=DriverManager.getConnection(dburl, username, password);
			return "";
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, "无法连接到数据库,请进入设置窗体进行设置!详细信息:\n"+e);
			return e.toString();
		}
	}
}
